/**
 * 数据库相关配置
 */

// 本地数据库名称
const String dbName = "xsj";

// 当前数据库版本
const int dbVersion = 1;

// 各表的版本及对应的表结构
const List<Map> tables = [
  /**
   * 贸易商表
    * id (主键)
    * merchant_name (贸易商姓名)
    * phone (电话)
    * password (密码)
   */
  {
    'tablename': 'Merchant_table',
    'info': [
      {
        'version': 1,
        'sql': """
        CREATE TABLE [Merchant_table] (
        [id] VARCHAR(50) NOT NULL PRIMARY KEY,
        [merchant_name] VARCHAR(100) NOT NULL,
        [phone] VARCHAR(50) NOT NULL,
        [password] VARCHAR(100) NOT NULL
        );
      """,
        'insert': "insert into Merchant_table values('?','?','?','?');"
      },
    ]
  },
  /**
   * 订单表 (Order_table)
    * order_id (订单号)
    * product_name (产品名称)
    * quantity (数量)
    * total_price (总价)
    * status (状态)
    * create_time (创建时间)
    * expected_delivery_date (期望送达日期)
    * customer_code (客户代码)
    * logistics_info (物流信息，多个时间和地点)
   */
  {
    'tablename': 'Order_table',
    'info': [
      {
        'version': 1,
        'sql': """
        CREATE TABLE [Order_table] (
        [order_id] VARCHAR(50) NOT NULL PRIMARY KEY,
        [product_name] VARCHAR(100) NOT NULL,
        [quantity] INTEGER NOT NULL,
        [total_price] DECIMAL(10, 2) NOT NULL,
        [status] VARCHAR(50) NOT NULL,
        [create_time] DATETIME NOT NULL,
        [expected_delivery_date] DATETIME NOT NULL,
        [customer_code] VARCHAR(50) NOT NULL,
        [logistics_info] TEXT NULL,
        [address] VARCHAR(50) NOT NULL,
        [remarksInformation] VARCHAR(50) NOT NULL
        );
      """,
        'insert':
            "insert into Order_table values('?','?','?','?','?','?','?','?','?','?');"
      },
    ]
  },
  /**
   * 用户表 (User Table)
    * username (用户名)
    * customer_code (客户代码)
    * name (姓名)
    * password (密码)
    * phone (电话)
    * email (邮箱)
   */
  {
    'tablename': 'User_table',
    'info': [
      {
        'version': 1,
        'sql': """
        CREATE TABLE [User_table] (
          [username] VARCHAR(50) NOT NULL PRIMARY KEY,
          [customer_code] VARCHAR(50) NOT NULL,
          [name] VARCHAR(100) NOT NULL,
          [password] VARCHAR(100) NOT NULL,
          [phone] VARCHAR(50) NOT NULL,
          [email] VARCHAR(100) NOT NULL
        );
      """,
        'insert': "insert into User_table values('?','?','?','?','?','?');"
      },
    ]
  }
];

/// 数据库版本对应的各个表的版本
const List<Map> database = [
  {
    'version': 1,
    'tables': [
      {'tablename': 'Merchant_table', 'version': 1},
      {'tablename': 'Order_table', 'version': 1},
      {'tablename': 'User_table', 'version': 1},
    ]
  },
  // {
  //   'version': 2,
  //   'tables': [
  //     {'tablename': 'info_learn', 'version': 1},
  //     {'tablename': 'paper_industry', 'version': 2},
  //     {'tablename': 'paper_own_lib', 'version': 1},
  //     {'tablename': 'paper_own_question', 'version': 1},
  //     {'tablename': 'paper_own_setting', 'version': 1},
  //     {'tablename': 'question_lib', 'version': 1},
  //     {'tablename': 'sys_dictionary', 'version': 1},
  //   ]
  // }
];
